package cj.web.admin.dao;
/*
 *  
 *  
*/
import java.util.List;
import net.paoding.rose.jade.annotation.DAO;
import net.paoding.rose.jade.annotation.SQL;
import net.paoding.rose.jade.annotation.SQLParam;
import cj.web.admin.domain.Industry;

/**
 * 
 * @author 
 *
 */
@DAO
public interface IndustryDAO{
	
	@SQL("SELECT * FROM Industry WHERE title=:t.title, AND category=:t.category, AND abstractInfor=:t.abstractInfor, AND carouselImage=:t.carouselImage, AND content=:t.content, AND author=:t.author, AND releaseState=:t.releaseState, AND releaseAT=:t.releaseAT, AND orderNo=:t.orderNo, AND source=:t.source, AND qrCode=:t.qrCode, AND stickAT=:t.stickAT, AND deleteFlag=:t.deleteFlag, AND createUser=:t.createUser, AND createAT=:t.createAT, AND updateUser=:t.updateUser, AND updateAT=:t.updateAT, ORDER BY update_date DESC LIMIT :t.start,:t.end ")
    List<Industry> query(@SQLParam("t") Industry industry);
    
    @SQL("select id,title,category,abstractInfor,carouselImage,content,author,releaseState,releaseAT,stickAT,deleteFlag,createUser,createAT,updateUser,updateAT from Industry where id=:1")
    Industry queryById(int id);
    
    @SQL("INSERT INTO Industry (title,category,abstractInfor,carouselImage,content,author,releaseState,releaseAT,orderNo,stickAT,deleteFlag,createUser,createAT,updateUser,updateAT) VALUES (:t.title,:t.category,:t.abstractInfor,:t.carouselImage,:t.content,:t.author,:t.releaseState,:t.releaseAT,:t.orderNo,:t.stickAT,:t.deleteFlag,:t.createUser,:t.createAT,:t.updateUser,:t.updateAT)")
    void create(@SQLParam("t") Industry industry);
	
	@SQL("UPDATE Industry SET title=:t.title,category=:t.category,abstractInfor=:t.abstractInfor,carouselImage=:t.carouselImage,content=:t.content,author=:t.author,orderNo=:t.orderNo,updateUser=:t.updateUser,updateAT=:t.updateAT WHERE id=:t.id")
    void update(@SQLParam("t") Industry industry);
    
    @SQL("UPDATE Industry SET deleteFlag=0 WHERE id=:1")
    void deleteById(int id);

    @SQL("select id,title,category,abstractInfor,carouselImage,content,author,releaseState,releaseAT,orderNo,stickAT from Industry where deleteFlag=1 #if(:t.title!=''){ and title like '%##(:t.title)%' } #if(:t.category!=''){ and category=:t.category } order by stickAT desc,updateAT desc limit :t.start, :t.length")
	List<Industry> list(@SQLParam("t")Industry industry);
    
    @SQL("select count(1) from Industry where deleteFlag=1 #if(:t.title!=''){ and title like '%##(:t.title)%' } #if(:t.category!=''){ and category=:t.category }")
    int size(@SQLParam("t")Industry industry);

    @SQL("UPDATE Industry SET stickAT=now() WHERE id=:1")
	void updateByStickTime(int id);

    @SQL("UPDATE Industry SET stickAT=null WHERE id=:1")
	void updateByStickTimeIsNull(int id);
	
	
}